package com.itheima.tliasmanagent.mapper;

import com.github.pagehelper.Page;
import com.itheima.tliasmanagent.pojo.Emp;
import com.itheima.tliasmanagent.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


    //@Select("select e.*,d.name as deptName from emp e left join  dept d on e.dept_id=d.id ")
    public Page<Emp> list(EmpQueryParam empQueryParam);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) VALUES \n" +
            "            (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime}) ")
    void insert(Emp emp);


    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void update(Emp emp);

    List<Map<String, Object>> countEmpJobData();

    List<Map> getEmpGenderData();

  /*  @Select("select count(*) from emp e left join  dept d on e.dept_id=d.id")
    Long count();*/

    public List<Map> getJobData();


    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getUsernameAndPassword(Emp emp);
}
